Basic demos

This is a short list of the interactive demonstrations we have built to illustrate basic background concepts. These are important for students to understand before they dive into machine learning.

In [ ]:
This is based off of Python Jupyter notebooks

Press the botton 'Toggle code' below to toggle code on and off for entire this presentation.

In [1]:
from IPython.display import display
from IPython.display import HTML
import IPython.core.display as di # Example: di.display_html('<h3>%s:</h3>' % str, raw=True)

# This line will hide code by default when the notebook is exported as HTML
di.display_html('<script>jQuery(function() {if (jQuery("body.notebook_app").length == 0) { jQuery(".input_area").toggle(); jQuery(".prompt").toggle();}});</script>', raw=True)

# This line will add a button to toggle visibility of code blocks, for use with the HTML export version
di.display_html('''<button onclick="jQuery('.input_area').toggle(); jQuery('.prompt').toggle();">Toggle code</button>''', raw=True)
In [2]:
# This code cell will not be shown in the HTML version of this notebook
# run this cell to import all necessary libraries for the notebook experiments
import sys
sys.path.append('../../')
from mlrefined_libraries import basics_library as baslib
from mlrefined_libraries import calculus_library as calclib
from mlrefined_libraries import linear_algebra_library as linlib

import autograd.numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# this is needed to compensate for matplotlib notebook's tendancy to blow up images when plotted inline
%matplotlib notebook
from matplotlib import rcParams
rcParams['figure.autolayout'] = True

From the most basic - e.g., animating sine / cosine.

In [2]:
# create an animation showing the origin of the sine and cosine functions
baslib.trig_hyper_visualizer.sin_cos(num_frames=200)
Out[2]:



To more moderate material like e.g., Taylor Series approximations to a function.

In [3]:
# what function should we play with?  Defined in the next line.
g = lambda w: np.sin(2*w)

# create an instance of the visualizer with this function 
taylor_viz = calclib.taylor_series_simultaneous_approximations.visualizer(g = g)

# run the visualizer for our chosen input function
taylor_viz.draw_it(num_frames = 200)
Out[3]:



...and the geometry of a hyperplane (with directions of steepest ascent / descent shown in the input space)

In [4]:
# define hyperplane
func = lambda w:  2 -2*w[0] - 2*w[1] 

# animate 2d slope visualizer
calclib.slope_visualizer.animate_visualize3d(func=func,num_frames=100)
Out[4]:



In [ ]:
 
In [ ]:
 
In [12]:
# what function should we play with?  Defined in the next line.
g = lambda w: np.sin(3*w) + 0.1*w**2

# create an instance of the visualizer with this function 
taylor_viz = calclib.second_order_convexity.visualizer(g = g)

# run the visualizer for our chosen input function
taylor_viz.draw_it(num_frames = 200,max_val = 3.5)
Out[12]: